﻿using	System;
using	System.Runtime.InteropServices;

namespace CSmcCs
{
	public class CSmc
	{
		//*******************************************************
		//       API-SMC(WDM)
		//       FILE NAME       CSMC.CS
		//********************************************************
		/* --------- THESE STRUCTS ARE USED BY USER --------- */
		//-----------------------------
		// API-SMC(WDM) Function List
		//-----------------------------
		[DllImport("CSmc.dll")] static extern int SmcWGetDeviceInfo(string Device, short InfoType, ref int Param1, ref int Param2, ref int Param3);
		[DllImport("CSmc.dll")] static extern int SmcWQueryDeviceName(short Index, System.Text.StringBuilder DeviceName, System.Text.StringBuilder Device);
		
		//---------------------------
		// Initialization Functions
		//---------------------------
		[DllImport("CSmc.dll")] static extern int SmcWInit(string DeviceName, ref short DevId);
		[DllImport("CSmc.dll")] static extern int SmcWExit(short DevId);
		[DllImport("CSmc.dll")] static extern int SmcWGetErrorString(int ErrorCode, System.Text.StringBuilder ErrorString);

		//---------------------------------------
		// Initial Parameters Setting Functions
		//---------------------------------------
		[DllImport("CSmc.dll")] static extern int SmcWSetPulseType(short DevId, short AxisNo, short PulseMode, short DirTimer);
		[DllImport("CSmc.dll")] static extern int SmcWGetPulseType(short DevId, short AxisNo, ref short PulseMode, ref short DirTimer);
		[DllImport("CSmc.dll")] static extern int SmcWSetPulseDuty(short DevId, short AxisNo, short Duty);
		[DllImport("CSmc.dll")] static extern int SmcWGetPulseDuty(short DevId, short AxisNo, ref short Duty);
		[DllImport("CSmc.dll")] static extern int SmcWSetEncType(short DevId, short AxisNo, short EncType);
		[DllImport("CSmc.dll")] static extern int SmcWGetEncType(short DevId, short AxisNo, ref short EncType);
		[DllImport("CSmc.dll")] static extern int SmcWSetCtrlTypeOut(short DevId, short AxisNo, short CtrlOut1, short CtrlOut2, short CtrlOut3);
		[DllImport("CSmc.dll")] static extern int SmcWGetCtrlTypeOut(short DevId, short AxisNo, ref short CtrlOut1, ref short CtrlOut2, ref short CtrlOut3);
		[DllImport("CSmc.dll")] static extern int SmcWSetCtrlTypeIn(short DevId, short AxisNo, short CtrlIn);
		[DllImport("CSmc.dll")] static extern int SmcWGetCtrlTypeIn(short DevId, short AxisNo, ref short CtrlIn);
		[DllImport("CSmc.dll")] static extern int SmcWSetOrgLog(short DevId, short AxisNo, short OrgLog);
		[DllImport("CSmc.dll")] static extern int SmcWGetOrgLog(short DevId, short AxisNo, ref short OrgLog);
		[DllImport("CSmc.dll")] static extern int SmcWSetCtrlInOutLog(short DevId, short AxisNo, short CtrlInOutLog);
		[DllImport("CSmc.dll")] static extern int SmcWGetCtrlInOutLog(short DevId, short AxisNo, ref short CtrlInOutLog);
		[DllImport("CSmc.dll")] static extern int SmcWSetErcMode(short DevId, short AxisNo, short ErcMode);
		[DllImport("CSmc.dll")] static extern int SmcWGetErcMode(short DevId, short AxisNo, ref short ErcMode);
		[DllImport("CSmc.dll")] static extern int SmcWSetErcAlmClearTime(short DevId, short AxisNo, short ErcTime, short ErcOffTimer, short AlmTime);
		[DllImport("CSmc.dll")] static extern int SmcWGetErcAlmClearTime(short DevId, short AxisNo, ref short ErcTime, ref short ErcOffTimer, ref short AlmTime);
		[DllImport("CSmc.dll")] static extern int SmcWSetOrgMode(short DevId, short AxisNo, short LimitTurn, short OrgType, short EndDir, short ZCount);
		[DllImport("CSmc.dll")] static extern int SmcWGetOrgMode(short DevId, short AxisNo, ref short LimitTurn, ref short OrgType, ref short EndDir, ref short ZCount);
		[DllImport("CSmc.dll")] static extern int SmcWSetSAccelType(short DevId, short AxisNo, short SAccelType);
		[DllImport("CSmc.dll")] static extern int SmcWGetSAccelType(short DevId, short AxisNo, ref short SAccelType);
		[DllImport("CSmc.dll")] static extern int SmcWSetInFilterType(short DevId, short AxisNo, short FilterType);
		[DllImport("CSmc.dll")] static extern int SmcWGetInFilterType(short DevId, short AxisNo, ref short FilterType);
		[DllImport("CSmc.dll")] static extern int SmcWSetSDMode(short DevId, short AxisNo, short SDMode);
		[DllImport("CSmc.dll")] static extern int SmcWGetSDMode(short DevId, short AxisNo, ref short SDMode);
		[DllImport("CSmc.dll")] static extern int SmcWSetCounterMode(short DevId, short AxisNo, short ClrCounterLtc, short LtcMode, short ClrCounterClr, short ClrMode);
		[DllImport("CSmc.dll")] static extern int SmcWGetCounterMode(short DevId, short AxisNo, ref short ClrCounterLtc, ref short LtcMode, ref short ClrCounterClr, ref short ClrMode);
		[DllImport("CSmc.dll")] static extern int SmcWSetSoftLimit(short DevId, short AxisNo, short PLimMode, short MLimMode, int PLimCount, int MLimCount);
		[DllImport("CSmc.dll")] static extern int SmcWGetSoftLimit(short DevId, short AxisNo, ref short PLimMode, ref short MLimMode, ref int PLimCount, ref int MLimCount);
		[DllImport("CSmc.dll")] static extern int SmcWSetInitParam(short DevId, short AxisNo);
		[DllImport("CSmc.dll")] static extern int SmcWGetInitParam(short DevId, short AxisNo, ref short InitParam);

		//------------------------------------
		// Basic Operation Setting Functions
		//------------------------------------
		[DllImport("CSmc.dll")] static extern int SmcWSetReady(short DevId, short AxisNo, short MotionType, short StartDir);
		[DllImport("CSmc.dll")] static extern int SmcWGetReady(short DevId, short AxisNo, ref short MotionType, ref short StartDir);
		[DllImport("CSmc.dll")] static extern int SmcWSetResolveSpeed(short DevId, short AxisNo, double ResolveSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWGetResolveSpeed(short DevId, short AxisNo, ref double ResolveSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWSetStartSpeed(short DevId, short AxisNo, double StartSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWGetStartSpeed(short DevId, short AxisNo, ref double StartSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWSetTargetSpeed(short DevId, short AxisNo, double TargetSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWGetTargetSpeed(short DevId, short AxisNo, ref double TargetSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWSetAccelTime(short DevId, short AxisNo, double AccelTime);
		[DllImport("CSmc.dll")] static extern int SmcWGetAccelTime(short DevId, short AxisNo, ref double AccelTime);
		[DllImport("CSmc.dll")] static extern int SmcWSetDecelTime(short DevId, short AxisNo, double DecelTime);
		[DllImport("CSmc.dll")] static extern int SmcWGetDecelTime(short DevId, short AxisNo, ref double DecelTime);
		[DllImport("CSmc.dll")] static extern int SmcWSetSSpeed(short DevId, short AxisNo, double SSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWGetSSpeed(short DevId, short AxisNo, ref double SSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWSetStopPosition(short DevId, short AxisNo, short Coodinate, int StopPosition);
		[DllImport("CSmc.dll")] static extern int SmcWGetStopPosition(short DevId, short AxisNo, short Coodinate, ref int StopPosition);
		[DllImport("CSmc.dll")] static extern int SmcWSetSync(short DevId, short SyncAxis, short SyncChip, short SyncBoard);
		[DllImport("CSmc.dll")] static extern int SmcWGetSync(short DevId, ref short SyncAxis, ref short SyncChip, ref short SyncBoard);
		[DllImport("CSmc.dll")] static extern int SmcWSetZCountMotion(short DevId, short AxisNo, short ZMoveCount, short ZLog);
		[DllImport("CSmc.dll")] static extern int SmcWGetZCountMotion(short DevId, short AxisNo, ref short ZMoveCount, ref short ZLog);

		//----------------------------------------
		//  Extended Operation Setting Functions 
		//----------------------------------------
		[DllImport("CSmc.dll")] static extern int SmcWSetBankNumber(short DevId, short AxisNo, short BankNum);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankNumber(short DevId, short AxisNo, ref short BankNum);
		[DllImport("CSmc.dll")] static extern int SmcWSetBankReady(short DevId, short AxisNo, short MotionType);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankReady(short DevId, short AxisNo, ref short MotionType);
		[DllImport("CSmc.dll")] static extern int SmcWSetBankDistance(short DevId, short AxisNo, short BankNo, int StopPosition);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankDistance(short DevId, short AxisNo, short BankNo, ref int StopPosition);
		[DllImport("CSmc.dll")] static extern int SmcWSetBankResolveSpeed(short DevId, short AxisNo, short BankNo, double ResolveSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankResolveSpeed(short DevId, short AxisNo, short BankNo, ref double ResolveSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWSetBankStartSpeed(short DevId, short AxisNo, short BankNo, double StartSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankStartSpeed(short DevId, short AxisNo, short BankNo, ref double StartSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWSetBankTargetSpeed(short DevId, short AxisNo, short BankNo, double TargetSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankTargetSpeed(short DevId, short AxisNo, short BankNo, ref double TargetSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWSetBankAccelTime(short DevId, short AxisNo, short BankNo, double AccelTime);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankAccelTime(short DevId, short AxisNo, short BankNo, ref double AccelTime);
		[DllImport("CSmc.dll")] static extern int SmcWSetBankDecelTime(short DevId, short AxisNo, short BankNo, double DecelTime);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankDecelTime(short DevId, short AxisNo, short BankNo, ref double DecelTime);
		[DllImport("CSmc.dll")] static extern int SmcWSetBankSSpeed(short DevId, short AxisNo, short BankNo, double SSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankSSpeed(short DevId, short AxisNo, short BankNo, ref double SSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWSetBankInterpolation(short DevId, short AxisNo, short BankNo, short InterType, short InterAxis, short Reserved);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankInterpolation(short DevId, short AxisNo, short BankNo, ref short InterType, ref short InterAxis, ref short Reserved);
		[DllImport("CSmc.dll")] static extern int SmcWSetBankArcPoint(short DevId, short AxisNo, short BankNo, double ArcSpeed, int Center_X, int Center_Y, int End_X, int End_Y);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankArcPoint(short DevId, short AxisNo, short BankNo, ref double ArcSpeed, ref int Center_X, ref int Center_Y, ref int End_X, ref int End_Y);
		[DllImport("CSmc.dll")] static extern int SmcWSetBankArcParam(short DevId, short AxisNo, short BankNo, short ArcStrtDir, short AutoEndPointPull);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankArcParam(short DevId, short AxisNo, short BankNo, ref short ArcStrtDir, ref short AutoEndPointPull);
		[DllImport("CSmc.dll")] static extern int SmcWSetBankContinuation(short DevId, short AxisNo, short BankNo, int ContType);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankContinuation(short DevId, short AxisNo, short BankNo, ref int ContType);

		//-----------------------------------
		// Control Signal Setting Functions
		//-----------------------------------
		[DllImport("CSmc.dll")] static extern int SmcWSetAlarmClear(short DevId, short AxisNo);
		[DllImport("CSmc.dll")] static extern int SmcWSetLimitMask(short DevId, short AxisNo, short LimitMask, short LimitMaskEnable);
		[DllImport("CSmc.dll")] static extern int SmcWGetLimitMask(short DevId, short AxisNo, ref short LimitMask);
		[DllImport("CSmc.dll")] static extern int SmcWSetDigitalOut(short DevId, short AxisNo, short OutData, short OutDataEnable);
		[DllImport("CSmc.dll")] static extern int SmcWGetDigitalOut(short DevId, short AxisNo, ref short OutData);
		[DllImport("CSmc.dll")] static extern int SmcWGetDigitalIn(short DevId, short AxisNo, ref short InData);
		[DllImport("CSmc.dll")] static extern int SmcWSetHoldOff(short DevId, short AxisNo, short HoldOff);
		[DllImport("CSmc.dll")] static extern int SmcWGetHoldOff(short DevId, short AxisNo, ref short HoldOff);
		[DllImport("CSmc.dll")] static extern int SmcWSetErcOut(short DevId, short AxisNo, short ErcOn);
		[DllImport("CSmc.dll")] static extern int SmcWGetAlarmCode(short DevId, short AxisNo, ref short AlarmCode);

		//----------------------------------
		// Operation Status Read Functions
		//----------------------------------
		[DllImport("CSmc.dll")] static extern int SmcWSetOutPulse(short DevId, short AxisNo, int OutPulse);
		[DllImport("CSmc.dll")] static extern int SmcWGetOutPulse(short DevId, short AxisNo, ref int OutPulse);
		[DllImport("CSmc.dll")] static extern int SmcWSetCountPulse(short DevId, short AxisNo, int CountPulse);
		[DllImport("CSmc.dll")] static extern int SmcWGetCountPulse(short DevId, short AxisNo, ref int CountPulse);
		[DllImport("CSmc.dll")] static extern int SmcWGetPulseStatus(short DevId, short AxisNo, ref short PulseSts);
		[DllImport("CSmc.dll")] static extern int SmcWGetMoveStatus(short DevId, short AxisNo, ref short MoveSts);
		[DllImport("CSmc.dll")] static extern int SmcWGetStopStatus(short DevId, short AxisNo, ref short StopSts);
		[DllImport("CSmc.dll")] static extern int SmcWGetLimitStatus(short DevId, short AxisNo, ref short LimitSts);
		[DllImport("CSmc.dll")] static extern int SmcWGetLatchOutPulse(short DevId, short AxisNo, ref int OutPulse);
		[DllImport("CSmc.dll")] static extern int SmcWGetLatchCountPulse(short DevId, short AxisNo, ref int CountPulse);
		[DllImport("CSmc.dll")] static extern int SmcWGetBankNo(short DevId, short AxisNo, ref short BankNo);
		[DllImport("CSmc.dll")] static extern int SmcWGetMoveSpeed(short DevId, short AxisNo, ref double MoveSpeed);
		[DllImport("CSmc.dll")] static extern int SmcWGetZCount(short DevId, short AxisNo, ref short MoveZCount);
        [DllImport("CSmc.dll")] static extern int SmcWGetCtrlInOutStatus(short DevId, short AxisNo, ref short CtrlSts);

		//-----------------------------
		// Motor Operation Functions
		//-----------------------------
		[DllImport("CSmc.dll")] static extern int SmcWMotionStart(short DevId, short AxisNo);
		[DllImport("CSmc.dll")] static extern int SmcWMotionStop(short DevId, short AxisNo);
		[DllImport("CSmc.dll")] static extern int SmcWMotionDecStop(short DevId, short AxisNo);
		[DllImport("CSmc.dll")] static extern int SmcWMotionChange(short DevId, short AxisNo);
		[DllImport("CSmc.dll")] static extern int SmcWSetMotionChangeReady(short DevId, short AxisNo, short ChangeType);
		[DllImport("CSmc.dll")] static extern int SmcWGetMotionChangeReady(short DevId, short AxisNo, ref short ChangeType);
		[DllImport("CSmc.dll")] static extern int SmcWSyncMotionStart(short DevId, short AxisNo);

		//------------------
		// Event Functions
		//------------------
		[DllImport("CSmc.dll")] static extern int SmcWStopEvent(short DevId, short AxisNo, IntPtr hMsgWnd, short EventMode);
		[DllImport("CSmc.dll")] static extern int SmcWBankEvent(short DevId, short AxisNo, IntPtr hMsgWnd, short EventMode, short BankNo);
		[DllImport("CSmc.dll")] static extern int SmcWCountEvent(short DevId, short AxisNo, IntPtr hMsgWnd, short EventMode, short CountType, int Count);
		[DllImport("CSmc.dll")] static extern int SmcWIrqEvent(short DevId, short AxisNo, IntPtr hMsgWnd, short EventMode, short EventType);

		// Constructor
		public CSmc()
		{
		}
		
		//-----------------------------
		// API-SMC(WDM) Function List
		//-----------------------------
		public int WGetDeviceInfo(string Device, short InfoType, out int Param1, out int Param2, out int Param3)
		{
			Param1 = 0;
			Param2 = 0;
			Param3 = 0;
			int ret = SmcWGetDeviceInfo(Device, InfoType, ref Param1, ref Param2, ref Param3);
			return ret;
		}
		public int WQueryDeviceName(short Index, out string DeviceName, out string Device)
		{
			DeviceName = new string('0', 1);
			Device = new string('0', 1);
			System.Text.StringBuilder devicename = new System.Text.StringBuilder(256);
			System.Text.StringBuilder device = new System.Text.StringBuilder(256);
			int ret = SmcWQueryDeviceName(Index, devicename, device);
			if( ret == 0 )
			{
				DeviceName = devicename.ToString();
				Device = device.ToString();
			}
			return ret;
		}
		
		//---------------------------
		// Initialization Functions
		//---------------------------
		public int WInit(string DeviceName, out short DevId)
		{
			DevId = 0;
			int ret = SmcWInit(DeviceName, ref DevId);
			return ret;
		}
		public int WExit(short DevId)
		{
			int ret = SmcWExit(DevId);
			return ret;
		}
		public int WGetErrorString(int ErrorCode, out string ErrorString)
		{
			ErrorString = new string('0', 1);
			System.Text.StringBuilder errorstring = new System.Text.StringBuilder(256);
			int ret = SmcWGetErrorString(ErrorCode, errorstring);
			if( ret == 0 )
			{
				ErrorString = errorstring.ToString();
			}
			return ret;
		}

		//---------------------------------------
		// Initial Parameters Setting Functions
		//---------------------------------------
		public int WSetPulseType(short DevId, short AxisNo, short PulseMode, short DirTimer)
		{
			int ret = SmcWSetPulseType(DevId, AxisNo, PulseMode, DirTimer);
			return ret;
		}
		public int WGetPulseType(short DevId, short AxisNo, out short PulseMode, out short DirTimer)
		{
			PulseMode = 0;
			DirTimer = 0;
			int ret = SmcWGetPulseType(DevId, AxisNo, ref PulseMode, ref DirTimer);
			return ret;
		}
		public int WSetPulseDuty(short DevId, short AxisNo, short Duty)
		{
			int ret = SmcWSetPulseDuty(DevId, AxisNo, Duty);
			return ret;
		}
		public int WGetPulseDuty(short DevId, short AxisNo, out short Duty)
		{
			Duty = 0;
			int ret = SmcWGetPulseDuty(DevId, AxisNo, ref Duty);
			return ret;
		}
		public int WSetEncType(short DevId, short AxisNo, short EncType)
		{
			int ret = SmcWSetEncType(DevId, AxisNo, EncType);
			return ret;
		}
		public int WGetEncType(short DevId, short AxisNo, out short EncType)
		{
			EncType = 0;
			int ret = SmcWGetEncType(DevId, AxisNo, ref EncType);
			return ret;
		}
		public int WSetCtrlTypeOut(short DevId, short AxisNo, short CtrlOut1, short CtrlOut2, short CtrlOut3)
		{
			int ret = SmcWSetCtrlTypeOut(DevId, AxisNo, CtrlOut1, CtrlOut2, CtrlOut3);
			return ret;
		}
		public int WGetCtrlTypeOut(short DevId, short AxisNo, out short CtrlOut1, out short CtrlOut2, out short CtrlOut3)
		{
			CtrlOut1 = 0;
			CtrlOut2 = 0;
			CtrlOut3 = 0;
			int ret = SmcWGetCtrlTypeOut(DevId, AxisNo, ref CtrlOut1, ref CtrlOut2, ref CtrlOut3);
			return ret;
		}
		public int WSetCtrlTypeIn(short DevId, short AxisNo, short CtrlIn)
		{
			int ret = SmcWSetCtrlTypeIn(DevId, AxisNo, CtrlIn);
			return ret;
		}
		public int WGetCtrlTypeIn(short DevId, short AxisNo, out short CtrlIn)
		{
			CtrlIn = 0;
			int ret = SmcWGetCtrlTypeIn(DevId, AxisNo, ref CtrlIn);
			return ret;
		}
		public int WSetOrgLog(short DevId, short AxisNo, short OrgLog)
		{
			int ret = SmcWSetOrgLog(DevId, AxisNo, OrgLog);
			return ret;
		}
		public int WGetOrgLog(short DevId, short AxisNo, out short OrgLog)
		{
			OrgLog = 0;
			int ret = SmcWGetOrgLog(DevId, AxisNo, ref OrgLog);
			return ret;
		}
		public int WSetCtrlInOutLog(short DevId, short AxisNo, short CtrlInOutLog)
		{
			int ret = SmcWSetCtrlInOutLog(DevId, AxisNo, CtrlInOutLog);
			return ret;
		}
		public int WGetCtrlInOutLog(short DevId, short AxisNo, out short CtrlInOutLog)
		{
			CtrlInOutLog = 0;
			int ret = SmcWGetCtrlInOutLog(DevId, AxisNo, ref CtrlInOutLog);
			return ret;
		}
		public int WSetErcMode(short DevId, short AxisNo, short ErcMode)
		{
			int ret = SmcWSetErcMode(DevId, AxisNo, ErcMode);
			return ret;
		}
		public int WGetErcMode(short DevId, short AxisNo, out short ErcMode)
		{
			ErcMode = 0;
			int ret = SmcWGetErcMode(DevId, AxisNo, ref ErcMode);
			return ret;
		}
		public int WSetErcAlmClearTime(short DevId, short AxisNo, short ErcTime, short ErcOffTimer, short AlmTime)
		{
			int ret = SmcWSetErcAlmClearTime(DevId, AxisNo, ErcTime, ErcOffTimer, AlmTime);
			return ret;
		}
		public int WGetErcAlmClearTime(short DevId, short AxisNo, out short ErcTime, out short ErcOffTimer, out short AlmTime)
		{
			ErcTime = 0;
			ErcOffTimer = 0;
			AlmTime = 0;
			int ret = SmcWGetErcAlmClearTime(DevId, AxisNo, ref ErcTime, ref ErcOffTimer, ref AlmTime);
			return ret;
		}
		public int WSetOrgMode(short DevId, short AxisNo, short LimitTurn, short OrgType, short EndDir, short ZCount)
		{
			int ret = SmcWSetOrgMode(DevId, AxisNo, LimitTurn, OrgType, EndDir, ZCount);
			return ret;
		}
		public int WGetOrgMode(short DevId, short AxisNo, out short LimitTurn, out short OrgType, out short EndDir, out short ZCount)
		{
			LimitTurn = 0;
			OrgType = 0;
			EndDir = 0;
			ZCount = 0;
			int ret = SmcWGetOrgMode(DevId, AxisNo, ref LimitTurn, ref OrgType, ref EndDir, ref ZCount);
			return ret;
		}
		public int WSetSAccelType(short DevId, short AxisNo, short SAccelType)
		{
			int ret = SmcWSetSAccelType(DevId, AxisNo, SAccelType);
			return ret;
		}
		public int WGetSAccelType(short DevId, short AxisNo, out short SAccelType)
		{
			SAccelType = 0;
			int ret = SmcWGetSAccelType(DevId, AxisNo, ref SAccelType);
			return ret;
		}
		public int WSetInFilterType(short DevId, short AxisNo, short FilterType)
		{
			int ret = SmcWSetInFilterType(DevId, AxisNo, FilterType);
			return ret;
		}
		public int WGetInFilterType(short DevId, short AxisNo, out short FilterType)
		{
			FilterType = 0;
			int ret = SmcWGetInFilterType(DevId, AxisNo, ref FilterType);
			return ret;
		}
		public int WSetSDMode(short DevId, short AxisNo, short SDMode)
		{
			int ret = SmcWSetSDMode(DevId, AxisNo, SDMode);
			return ret;
		}
		public int WGetSDMode(short DevId, short AxisNo, out short SDMode)
		{
			SDMode =0;
			int ret = SmcWGetSDMode(DevId, AxisNo, ref SDMode);
			return ret;
		}
		public int WSetCounterMode(short DevId, short AxisNo, short ClrCounterLtc, short LtcMode, short ClrCounterClr, short ClrMode)
		{
			int ret = SmcWSetCounterMode(DevId, AxisNo, ClrCounterLtc, LtcMode, ClrCounterClr, ClrMode);
			return ret;
		}
		public int WGetCounterMode(short DevId, short AxisNo, out short ClrCounterLtc, out short LtcMode, out short ClrCounterClr, out short ClrMode)
		{
			ClrCounterLtc = 0;
			LtcMode = 0;
			ClrCounterClr = 0;
			ClrMode = 0;
			int ret = SmcWGetCounterMode(DevId, AxisNo, ref ClrCounterLtc, ref LtcMode, ref ClrCounterClr, ref ClrMode);
			return ret;
		}
		public int WSetSoftLimit(short DevId, short AxisNo, short PLimMode, short MLimMode, int PLimCount, int MLimCount)
		{
			int ret = SmcWSetSoftLimit(DevId, AxisNo, PLimMode, MLimMode, PLimCount, MLimCount);
			return ret;
		}
		public int WGetSoftLimit(short DevId, short AxisNo, out short PLimMode, out short MLimMode, out int PLimCount, out int MLimCount)
		{
			PLimMode = 0;
			MLimMode = 0;
			PLimCount = 0;
			MLimCount = 0;
			int ret = SmcWGetSoftLimit(DevId, AxisNo, ref PLimMode, ref MLimMode, ref PLimCount, ref MLimCount);
			return ret;
		}
		public int WSetInitParam(short DevId, short AxisNo)
		{
			int ret = SmcWSetInitParam(DevId, AxisNo);
			return ret;
		}
		public int WGetInitParam(short DevId, short AxisNo, out short InitParam)
		{
			InitParam = 0;
			int ret = SmcWGetInitParam(DevId, AxisNo, ref InitParam);
			return ret;
		}

		//------------------------------------
		// Basic Operation Setting Functions
		//------------------------------------
		public int WSetReady(short DevId, short AxisNo, short MotionType, short StartDir)
		{
			int ret = SmcWSetReady(DevId, AxisNo, MotionType, StartDir);
			return ret;
		}
		public int WGetReady(short DevId, short AxisNo, out short MotionType, out short StartDir)
		{
			MotionType = 0;
			StartDir = 0;
			int ret = SmcWGetReady(DevId, AxisNo, ref MotionType, ref StartDir);
			return ret;
		}
		public int WSetResolveSpeed(short DevId, short AxisNo, double ResolveSpeed)
		{
			int ret = SmcWSetResolveSpeed(DevId, AxisNo, ResolveSpeed);
			return ret;
		}
		public int WGetResolveSpeed(short DevId, short AxisNo, out double ResolveSpeed)
		{
			ResolveSpeed = 0;
			int ret = SmcWGetResolveSpeed(DevId, AxisNo, ref ResolveSpeed);
			return ret;
		}
		public int WSetStartSpeed(short DevId, short AxisNo, double StartSpeed)
		{
			int ret = SmcWSetStartSpeed(DevId, AxisNo, StartSpeed);
			return ret;
		}
		public int WGetStartSpeed(short DevId, short AxisNo, out double StartSpeed)
		{
			StartSpeed = 0;
			int ret = SmcWGetStartSpeed(DevId, AxisNo, ref StartSpeed);
			return ret;
		}
		public int WSetTargetSpeed(short DevId, short AxisNo, double TargetSpeed)
		{
			int ret = SmcWSetTargetSpeed(DevId, AxisNo, TargetSpeed);
			return ret;
		}
		public int WGetTargetSpeed(short DevId, short AxisNo, out double TargetSpeed)
		{
			TargetSpeed = 0;
			int ret = SmcWGetTargetSpeed(DevId, AxisNo, ref TargetSpeed);
			return ret;
		}
		public int WSetAccelTime(short DevId, short AxisNo, double AccelTime)
		{
			int ret = SmcWSetAccelTime(DevId, AxisNo, AccelTime);
			return ret;
		}
		public int WGetAccelTime(short DevId, short AxisNo, out double AccelTime)
		{
			AccelTime = 0;
			int ret = SmcWGetAccelTime(DevId, AxisNo, ref AccelTime);
			return ret;
		}
		public int WSetDecelTime(short DevId, short AxisNo, double DecelTime)
		{
			int ret = SmcWSetDecelTime(DevId, AxisNo, DecelTime);
			return ret;
		}
		public int WGetDecelTime(short DevId, short AxisNo, out double DecelTime)
		{
			DecelTime = 0;
			int ret = SmcWGetDecelTime(DevId, AxisNo, ref DecelTime);
			return ret;
		}
		public int WSetSSpeed(short DevId, short AxisNo, double SSpeed)
		{
			int ret = SmcWSetSSpeed(DevId, AxisNo, SSpeed);
			return ret;
		}
		public int WGetSSpeed(short DevId, short AxisNo, out double SSpeed)
		{
			SSpeed = 0;
			int ret = SmcWGetSSpeed(DevId, AxisNo, ref SSpeed);
			return ret;
		}
		public int WSetStopPosition(short DevId, short AxisNo, short Coodinate, int StopPosition)
		{
			int ret = SmcWSetStopPosition(DevId, AxisNo, Coodinate, StopPosition);
			return ret;
		}
		public int WGetStopPosition(short DevId, short AxisNo, short Coodinate, out int StopPosition)
		{
			StopPosition = 0;
			int ret = SmcWGetStopPosition(DevId, AxisNo, Coodinate, ref StopPosition);
			return ret;
		}
		public int WSetSync(short DevId, short SyncAxis, short SyncChip, short SyncBoard)
		{
			int ret = SmcWSetSync(DevId, SyncAxis, SyncChip, SyncBoard);
			return ret;
		}
		public int WGetSync(short DevId, out short SyncAxis, out short SyncChip, out short SyncBoard)
		{
			SyncAxis = 0;
			SyncChip = 0;
			SyncBoard = 0;
			int ret = SmcWGetSync(DevId, ref SyncAxis, ref SyncChip, ref SyncBoard);
			return ret;
		}
		public int WSetZCountMotion(short DevId, short AxisNo, short ZMoveCount, short ZLog)
		{
			int ret = SmcWSetZCountMotion(DevId, AxisNo, ZMoveCount, ZLog);
			return ret;
		}
		public int WGetZCountMotion(short DevId, short AxisNo, out short ZMoveCount, out short ZLog)
		{
			ZMoveCount = 0;
			ZLog = 0;
			int ret = SmcWGetZCountMotion(DevId, AxisNo, ref ZMoveCount, ref ZLog);
			return ret;
		}

		//----------------------------------------
		//  Extended Operation Setting Functions 
		//----------------------------------------
		public int WSetBankNumber(short DevId, short AxisNo, short BankNum)
		{
			int ret = SmcWSetBankNumber(DevId, AxisNo, BankNum);
			return ret;
		}
		public int WGetBankNumber(short DevId, short AxisNo, out short BankNum)
		{
			BankNum = 0;
			int ret = SmcWGetBankNumber(DevId, AxisNo, ref BankNum);
			return ret;
		}
		public int WSetBankReady(short DevId, short AxisNo, short MotionType)
		{
			int ret = SmcWSetBankReady(DevId, AxisNo, MotionType);
			return ret;
		}
		public int WGetBankReady(short DevId, short AxisNo, out short MotionType)
		{
			MotionType = 0;
			int ret = SmcWGetBankReady(DevId, AxisNo, ref MotionType);
			return ret;
		}
		public int WSetBankDistance(short DevId, short AxisNo, short BankNo, int StopPosition)
		{
			int ret = SmcWSetBankDistance(DevId, AxisNo, BankNo, StopPosition);
			return ret;
		}
		public int WGetBankDistance(short DevId, short AxisNo, short BankNo, out int StopPosition)
		{
			StopPosition = 0;
			int ret = SmcWGetBankDistance(DevId, AxisNo, BankNo, ref StopPosition);
			return ret;
		}
		public int WSetBankResolveSpeed(short DevId, short AxisNo, short BankNo, double ResolveSpeed)
		{
			int ret = SmcWSetBankResolveSpeed(DevId, AxisNo, BankNo, ResolveSpeed);
			return ret;
		}
		public int WGetBankResolveSpeed(short DevId, short AxisNo, short BankNo, out double ResolveSpeed)
		{
			ResolveSpeed = 0;
			int ret = SmcWGetBankResolveSpeed(DevId, AxisNo, BankNo, ref ResolveSpeed);
			return ret;
		}
		public int WSetBankStartSpeed(short DevId, short AxisNo, short BankNo, double StartSpeed)
		{
			int ret = SmcWSetBankStartSpeed(DevId, AxisNo, BankNo, StartSpeed);
			return ret;
		}
		public int WGetBankStartSpeed(short DevId, short AxisNo, short BankNo, out double StartSpeed)
		{
			StartSpeed = 0;
			int ret = SmcWGetBankStartSpeed(DevId, AxisNo, BankNo, ref StartSpeed);
			return ret;
		}
		public int WSetBankTargetSpeed(short DevId, short AxisNo, short BankNo, double TargetSpeed)
		{
			int ret = SmcWSetBankTargetSpeed(DevId, AxisNo, BankNo, TargetSpeed);
			return ret;
		}
		public int WGetBankTargetSpeed(short DevId, short AxisNo, short BankNo, out double TargetSpeed)
		{
			TargetSpeed = 0;
			int ret = SmcWGetBankTargetSpeed(DevId, AxisNo, BankNo, ref TargetSpeed);
			return ret;
		}
		public int WSetBankAccelTime(short DevId, short AxisNo, short BankNo, double AccelTime)
		{
			int ret = SmcWSetBankAccelTime(DevId, AxisNo, BankNo, AccelTime);
			return ret;
		}
		public int WGetBankAccelTime(short DevId, short AxisNo, short BankNo, out double AccelTime)
		{
			AccelTime = 0;
			int ret = SmcWGetBankAccelTime(DevId, AxisNo, BankNo, ref AccelTime);
			return ret;
		}
		public int WSetBankDecelTime(short DevId, short AxisNo, short BankNo, double DecelTime)
		{
			int ret = SmcWSetBankDecelTime(DevId, AxisNo, BankNo, DecelTime);
			return ret;
		}
		public int WGetBankDecelTime(short DevId, short AxisNo, short BankNo, out double DecelTime)
		{
			DecelTime = 0;
			int ret = SmcWGetBankDecelTime(DevId, AxisNo, BankNo, ref DecelTime);
			return ret;
		}
		public int WSetBankSSpeed(short DevId, short AxisNo, short BankNo, double SSpeed)
		{
			int ret = SmcWSetBankSSpeed(DevId, AxisNo, BankNo, SSpeed);
			return ret;
		}
		public int WGetBankSSpeed(short DevId, short AxisNo, short BankNo, out double SSpeed)
		{
			SSpeed = 0;
			int ret = SmcWGetBankSSpeed(DevId, AxisNo, BankNo, ref SSpeed);
			return ret;
		}
		public int WSetBankInterpolation(short DevId, short AxisNo, short BankNo, short InterType, short InterAxis, short Reserved)
		{
			int ret = SmcWSetBankInterpolation(DevId, AxisNo, BankNo, InterType, InterAxis, Reserved);
			return ret;
		}
		public int WGetBankInterpolation(short DevId, short AxisNo, short BankNo, out short InterType, out short InterAxis, out short Reserved)
		{
			InterType = 0;
			InterAxis = 0;
			Reserved = 0;
			int ret = SmcWGetBankInterpolation(DevId, AxisNo, BankNo, ref InterType, ref InterAxis, ref Reserved);
			return ret;
		}
		public int WSetBankArcPoint(short DevId, short AxisNo, short BankNo, double ArcSpeed, int Center_X, int Center_Y, int End_X, int End_Y)
		{
			int ret = SmcWSetBankArcPoint(DevId, AxisNo, BankNo, ArcSpeed, Center_X, Center_Y, End_X, End_Y);
			return ret;
		}
		public int WGetBankArcPoint(short DevId, short AxisNo, short BankNo, out double ArcSpeed, out int Center_X, out int Center_Y, out int End_X, out int End_Y)
		{
			ArcSpeed = 0;
			Center_X = 0;
			Center_Y = 0;
			End_X = 0;
			End_Y = 0;
			int ret = SmcWGetBankArcPoint(DevId, AxisNo, BankNo, ref ArcSpeed, ref Center_X, ref Center_Y, ref End_X, ref End_Y);
			return ret;
		}
		public int WSetBankArcParam(short DevId, short AxisNo, short BankNo, short ArcStrtDir, short AutoEndPointPull)
		{
			int ret = SmcWSetBankArcParam(DevId, AxisNo, BankNo, ArcStrtDir, AutoEndPointPull);
			return ret;
		}
		public int WGetBankArcParam(short DevId, short AxisNo, short BankNo, out short ArcStrtDir, out short AutoEndPointPull)
		{
			ArcStrtDir = 0;
			AutoEndPointPull = 0;
			int ret = SmcWGetBankArcParam(DevId, AxisNo, BankNo, ref ArcStrtDir, ref AutoEndPointPull);
			return ret;
		}
		public int WSetBankContinuation(short DevId, short AxisNo, short BankNo, int ContType)
		{
			int ret = SmcWSetBankContinuation(DevId, AxisNo, BankNo, ContType);
			return ret;
		}
		public int WGetBankContinuation(short DevId, short AxisNo, short BankNo, out int ContType)
		{
			ContType = 0;
			int ret = SmcWGetBankContinuation(DevId, AxisNo, BankNo, ref ContType);
			return ret;
		}

		//-----------------------------------
		// Control Signal Setting Functions
		//-----------------------------------
		public int WSetAlarmClear(short DevId, short AxisNo)
		{
			int ret = SmcWSetAlarmClear(DevId, AxisNo);
			return ret;
		}
		public int WSetLimitMask(short DevId, short AxisNo, short LimitMask, short LimitMaskEnable)
		{
			int ret = SmcWSetLimitMask(DevId, AxisNo, LimitMask, LimitMaskEnable);
			return ret;
		}
		public int WGetLimitMask(short DevId, short AxisNo, out short LimitMask)
		{
			LimitMask = 0;
			int ret = SmcWGetLimitMask(DevId, AxisNo, ref LimitMask);
			return ret;
		}
		public int WSetDigitalOut(short DevId, short AxisNo, short OutData, short OutDataEnable)
		{
			int ret = SmcWSetDigitalOut(DevId, AxisNo, OutData, OutDataEnable);
			return ret;
		}
		public int WGetDigitalOut(short DevId, short AxisNo, out short OutData)
		{
			OutData = 0;
			int ret = SmcWGetDigitalOut(DevId, AxisNo, ref OutData);
			return ret;
		}
		public int WGetDigitalIn(short DevId, short AxisNo, out short InData)
		{
			InData = 0;
			int ret = SmcWGetDigitalIn(DevId, AxisNo, ref InData);
			return ret;
		}
		public int WSetHoldOff(short DevId, short AxisNo, short HoldOff)
		{
			int ret = SmcWSetHoldOff(DevId, AxisNo, HoldOff);
			return ret;
		}
		public int WGetHoldOff(short DevId, short AxisNo, out short HoldOff)
		{
			HoldOff = 0;
			int ret = SmcWGetHoldOff(DevId, AxisNo, ref HoldOff);
			return ret;
		}
		public int WSetErcOut(short DevId, short AxisNo, short ErcOn)
		{
			int ret = SmcWSetErcOut(DevId, AxisNo, ErcOn);
			return ret;
		}
		public int WGetAlarmCode(short DevId, short AxisNo, out short AlarmCode)
		{
			AlarmCode = 0;
			int ret = SmcWGetAlarmCode(DevId, AxisNo, ref AlarmCode);
			return ret;
		}

		//----------------------------------
		// Operation Status Read Functions
		//----------------------------------
		public int WSetOutPulse(short DevId, short AxisNo, int OutPulse)
		{
			int ret = SmcWSetOutPulse(DevId, AxisNo, OutPulse);
			return ret;
		}
		public int WGetOutPulse(short DevId, short AxisNo, out int OutPulse)
		{
			OutPulse = 0;
			int ret = SmcWGetOutPulse(DevId, AxisNo, ref OutPulse);
			return ret;
		}
		public int WSetCountPulse(short DevId, short AxisNo, int CountPulse)
		{
			int ret = SmcWSetCountPulse(DevId, AxisNo, CountPulse);
			return ret;
		}
		public int WGetCountPulse(short DevId, short AxisNo, out int CountPulse)
		{
			CountPulse = 0;
			int ret = SmcWGetCountPulse(DevId, AxisNo, ref CountPulse);
			return ret;
		}
		public int WGetPulseStatus(short DevId, short AxisNo, out short PulseSts)
		{
			PulseSts = 0;
			int ret = SmcWGetPulseStatus(DevId, AxisNo, ref PulseSts);
			return ret;
		}
		public int WGetMoveStatus(short DevId, short AxisNo, out short MoveSts)
		{
			MoveSts = 0;
			int ret = SmcWGetMoveStatus(DevId, AxisNo, ref MoveSts);
			return ret;
		}
		public int WGetStopStatus(short DevId, short AxisNo, out short StopSts)
		{
			StopSts = 0;
			int ret = SmcWGetStopStatus(DevId, AxisNo, ref StopSts);
			return ret;
		}
		public int WGetLimitStatus(short DevId, short AxisNo, out short LimitSts)
		{
			LimitSts = 0;
			int ret = SmcWGetLimitStatus(DevId, AxisNo, ref LimitSts);
			return ret;
		}
		public int WGetLatchOutPulse(short DevId, short AxisNo, out int OutPulse)
		{
			OutPulse = 0;
			int ret = SmcWGetLatchOutPulse(DevId, AxisNo, ref OutPulse);
			return ret;
		}
		public int WGetLatchCountPulse(short DevId, short AxisNo, out int CountPulse)
		{
			CountPulse = 0;
			int ret = SmcWGetLatchCountPulse(DevId, AxisNo, ref CountPulse);
			return ret;
		}
		public int WGetBankNo(short DevId, short AxisNo, out short BankNo)
		{
			BankNo = 0;
			int ret = SmcWGetBankNo(DevId, AxisNo, ref BankNo);
			return ret;
		}
		public int WGetMoveSpeed(short DevId, short AxisNo, out double MoveSpeed)
		{
			MoveSpeed = 0;
			int ret = SmcWGetMoveSpeed(DevId, AxisNo, ref MoveSpeed);
			return ret;
		}
        public int WGetZCount(short DevId, short AxisNo, out short MoveZCount)
        {
            MoveZCount = 0;
            int ret = SmcWGetZCount(DevId, AxisNo, ref MoveZCount);
            return ret;
        }
        public int WGetCtrlInOutStatus(short DevId, short AxisNo, out short CtrlSts)
        {
            CtrlSts = 0;
            int ret = SmcWGetCtrlInOutStatus(DevId, AxisNo, ref CtrlSts);
            return ret;
        }

		//-----------------------------
		// Motor Operation Functions
		//-----------------------------
		public int WMotionStart(short DevId, short AxisNo)
		{
			int ret = SmcWMotionStart(DevId, AxisNo);
			return ret;
		}
		public int WMotionStop(short DevId, short AxisNo)
		{
			int ret = SmcWMotionStop(DevId, AxisNo);
			return ret;
		}
		public int WMotionDecStop(short DevId, short AxisNo)
		{
			int ret = SmcWMotionDecStop(DevId, AxisNo);
			return ret;
		}
		public int WMotionChange(short DevId, short AxisNo)
		{
			int ret = SmcWMotionChange(DevId, AxisNo);
			return ret;
		}
		public int WSetMotionChangeReady(short DevId, short AxisNo, short ChangeType)
		{
			int ret = SmcWSetMotionChangeReady(DevId, AxisNo, ChangeType);
			return ret;
		}
		public int WGetMotionChangeReady(short DevId, short AxisNo, out short ChangeType)
		{
			ChangeType = 0;
			int ret = SmcWGetMotionChangeReady(DevId, AxisNo, ref ChangeType);
			return ret;
		}
		public int WSyncMotionStart(short DevId, short AxisNo)
		{
			int ret = SmcWSyncMotionStart(DevId, AxisNo);
			return ret;
		}

		//------------------
		// Event Functions
		//------------------
		public int WStopEvent(short DevId, short AxisNo, IntPtr hMsgWnd, short EventMode)
		{
			int ret = SmcWStopEvent(DevId, AxisNo, hMsgWnd, EventMode);
			return ret;
		}
		public int WBankEvent(short DevId, short AxisNo, IntPtr hMsgWnd, short EventMode, short BankNo)
		{
			int ret = SmcWBankEvent(DevId, AxisNo, hMsgWnd, EventMode, BankNo);
			return ret;
		}
		public int WCountEvent(short DevId, short AxisNo, IntPtr hMsgWnd, short EventMode, short CountType, int Count)
		{
			int ret = SmcWCountEvent(DevId, AxisNo, hMsgWnd, EventMode, CountType, Count);
			return ret;
		}
		public int WIrqEvent(short DevId, short AxisNo, IntPtr hMsgWnd, short EventMode, short EventType)
		{
			int ret = SmcWIrqEvent(DevId, AxisNo, hMsgWnd, EventMode, EventType);
			return ret;
		}

	}
}
